package com.haofengsoft.scce.db.biz.consultation;

import java.util.List;

import android.content.Context;

import com.haofengsoft.scce.ManageApplication;
import com.haofengsoft.scce.db.DaoSession;
import com.haofengsoft.scce.db.dao.consultation.ShangHaiDao;
import com.haofengsoft.scce.db.entity.consultation.ShangHai;

import de.greenrobot.dao.query.QueryBuilder;

/**
 * Created by admin on 2015/7/23.
 */
public class ShangHaiBiz {
	private static ShangHaiBiz instance;
	private static Context appContext;
	private ShangHaiDao dao;

	private ShangHaiBiz() {
	}

	public static ShangHaiBiz getInstance(Context context) {
		if (instance == null) {
			instance = new ShangHaiBiz();
			if (appContext == null) {
				appContext = context.getApplicationContext();
			}
			DaoSession daoSession = ManageApplication.getDaoSession(context);
			instance.dao = daoSession.getShangHaiDao();
		}
		return instance;
	}

	public void insertShangHaiList(final List<ShangHai> infoList) {
		dao.insertOrReplaceInTx(infoList);
	}

	public List<ShangHai> gainShangHaiList() {
		QueryBuilder qb = dao.queryBuilder();
		return qb.list();
	}
}
